package com.rickpan.dto.request;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.rickpan.entity.GeneratedReport;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 报告管理相关请求DTO
 */
public class ReportManageRequest {

    /**
     * 报告查询请求
     */
    @Schema(description = "报告查询请求")
    public static class ReportQueryRequest {
        
        @Schema(description = "页码，从0开始", example = "0")
        private Integer page = 0;
        
        @Schema(description = "每页大小", example = "10")
        private Integer size = 10;
        
        @Schema(description = "报告类型", allowableValues = {"DAILY", "WEEKLY", "MONTHLY"})
        private GeneratedReport.ReportType type;
        
        @Schema(description = "报告状态", allowableValues = {"DRAFT", "FINAL", "ARCHIVED"})
        private GeneratedReport.ReportStatus status;
        
        @Schema(description = "搜索关键词")
        private String keyword;
        
        @Schema(description = "开始日期", example = "2025-01-01")
        @JsonFormat(pattern = "yyyy-MM-dd")
        private LocalDate startDate;
        
        @Schema(description = "结束日期", example = "2025-01-31")
        @JsonFormat(pattern = "yyyy-MM-dd")
        private LocalDate endDate;
        
        @Schema(description = "排序字段", example = "createdAt")
        private String sortBy = "createdAt";
        
        @Schema(description = "排序方向", allowableValues = {"ASC", "DESC"}, example = "DESC")
        private String sortDirection = "DESC";

        // Getter和Setter方法
        public Integer getPage() { return page; }
        public void setPage(Integer page) { this.page = page; }

        public Integer getSize() { return size; }
        public void setSize(Integer size) { this.size = size; }

        public GeneratedReport.ReportType getType() { return type; }
        public void setType(GeneratedReport.ReportType type) { this.type = type; }

        public GeneratedReport.ReportStatus getStatus() { return status; }
        public void setStatus(GeneratedReport.ReportStatus status) { this.status = status; }

        public String getKeyword() { return keyword; }
        public void setKeyword(String keyword) { this.keyword = keyword; }

        public LocalDate getStartDate() { return startDate; }
        public void setStartDate(LocalDate startDate) { this.startDate = startDate; }

        public LocalDate getEndDate() { return endDate; }
        public void setEndDate(LocalDate endDate) { this.endDate = endDate; }

        public String getSortBy() { return sortBy; }
        public void setSortBy(String sortBy) { this.sortBy = sortBy; }

        public String getSortDirection() { return sortDirection; }
        public void setSortDirection(String sortDirection) { this.sortDirection = sortDirection; }
    }

    /**
     * 报告更新请求
     */
    @Schema(description = "报告更新请求")
    public static class ReportUpdateRequest {
        
        @Schema(description = "报告标题", example = "2025-01-10 工作日报")
        @NotBlank(message = "报告标题不能为空")
        @Size(max = 200, message = "报告标题长度不能超过200字符")
        private String title;
        
        @Schema(description = "编辑后的报告内容")
        @NotBlank(message = "报告内容不能为空")
        private String editedContent;
        
        @Schema(description = "报告状态", allowableValues = {"DRAFT", "FINAL", "ARCHIVED"})
        @NotNull(message = "报告状态不能为空")
        private GeneratedReport.ReportStatus status;
        
        @Schema(description = "报告标签")
        private List<String> tags;

        // Getter和Setter方法
        public String getTitle() { return title; }
        public void setTitle(String title) { this.title = title; }

        public String getEditedContent() { return editedContent; }
        public void setEditedContent(String editedContent) { this.editedContent = editedContent; }

        public GeneratedReport.ReportStatus getStatus() { return status; }
        public void setStatus(GeneratedReport.ReportStatus status) { this.status = status; }

        public List<String> getTags() { return tags; }
        public void setTags(List<String> tags) { this.tags = tags; }
    }

    /**
     * 批量操作请求
     */
    @Schema(description = "批量操作请求")
    public static class BatchOperationRequest {
        
        @Schema(description = "报告ID列表", example = "[1, 2, 3]")
        @NotNull(message = "报告ID列表不能为空")
        @Size(min = 1, message = "至少选择一个报告")
        private List<Long> reportIds;
        
        @Schema(description = "操作类型", allowableValues = {"DELETE", "ARCHIVE", "EXPORT"})
        @NotNull(message = "操作类型不能为空")
        private String operation;

        // Getter和Setter方法
        public List<Long> getReportIds() { return reportIds; }
        public void setReportIds(List<Long> reportIds) { this.reportIds = reportIds; }

        public String getOperation() { return operation; }
        public void setOperation(String operation) { this.operation = operation; }
    }

    /**
     * 报告导出请求
     */
    @Schema(description = "报告导出请求")
    public static class ReportExportRequest {
        
        @Schema(description = "报告ID", example = "1")
        @NotNull(message = "报告ID不能为空")
        private Long reportId;
        
        @Schema(description = "导出格式", allowableValues = {"PDF", "WORD", "MARKDOWN"}, example = "PDF")
        @NotBlank(message = "导出格式不能为空")
        private String format;
        
        @Schema(description = "是否包含原始内容", example = "false")
        private Boolean includeOriginal = false;

        // Getter和Setter方法
        public Long getReportId() { return reportId; }
        public void setReportId(Long reportId) { this.reportId = reportId; }

        public String getFormat() { return format; }
        public void setFormat(String format) { this.format = format; }

        public Boolean getIncludeOriginal() { return includeOriginal; }
        public void setIncludeOriginal(Boolean includeOriginal) { this.includeOriginal = includeOriginal; }
    }
}
